package com.malamute.system.service.impl;

import java.util.Set;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.malamute.core.common.Page;
import com.malamute.system.dao.TreeNodeDao;
import com.malamute.system.entity.TreeNode;
import com.malamute.system.service.TreeNodeService;

/**
 * @author Aceguan
 * @description 树节点业务接口实现
 * @date 2012-2-23 下午06:00:16
 * @version v1.0
 */
@Service
public class TreeNodeServiceImpl implements TreeNodeService {
	@Autowired
	private TreeNodeDao treeNodeDao;

	public void setTreeNodeDao(TreeNodeDao treeNodeDao) {
		this.treeNodeDao = treeNodeDao;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param treeNode
	 * 
	 * @see
	 * com.malamute.system.service.TreeNodeService#saveTreeNode(com.malamute
	 * .system.entity.TreeNode)
	 */
	@Override
	public void saveTreeNode(TreeNode treeNode) {
		treeNodeDao.save(treeNode);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param treeNode
	 * 
	 * @see
	 * com.malamute.system.service.TreeNodeService#updateTreeNode(com.malamute
	 * .system.entity.TreeNode)
	 */
	@Override
	public void updateTreeNode(TreeNode treeNode) {
		treeNodeDao.update(treeNode);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param criteria
	 * 
	 * @param page
	 * 
	 * @see
	 * com.malamute.system.service.TreeNodeService#listTreeNodesByPage(org.hibernate
	 * .criterion.DetachedCriteria, com.malamute.core.common.Page)
	 */
	@Override
	public void listTreeNodesByPage(DetachedCriteria criteria, Page page) {
		treeNodeDao.listByPage(criteria, page);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param id
	 * 
	 * @return
	 * 
	 * @see
	 * com.malamute.system.service.TreeNodeService#getTreeNodeById(java.lang
	 * .Integer)
	 */
	@Override
	public TreeNode getTreeNodeById(Integer id) {
		return treeNodeDao.get(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param id
	 * 
	 * @see
	 * com.malamute.system.service.TreeNodeService#deleteTreeNodeById(java.lang
	 * .Integer)
	 */
	@Override
	public void deleteTreeNodeById(Integer id) {
		treeNodeDao.deleteByKey(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param parent
	 * 
	 * @see
	 * com.malamute.system.service.TreeNodeService#listTreeNodesByParent(com
	 * .malamute.system.entity.TreeNode)
	 */
	@Override
	public Set listTreeNodesByParent(TreeNode parent) {
		return parent.getChildren();
	}

}
